// custom-tab-bar/index.js
Component({
    data: {
        active: 0,
        //路径
        list: [{
            pagePath: "/pages/home/home",
            text: "首页",
            iconPath: "wap-home-o",
            selectedIconPath: "wap-home-o"
          }, {
            pagePath: "/pages/category/category",
            text: "分类",
            iconPath: "apps-o",
            selectedIconPath: "apps-o"
            
          },{
            pagePath: "/pages/topic/topic",
            text: "专题",
            iconPath: "point-gift-o",
            selectedIconPath: "point-gift-o"
            
          },
          {
            pagePath: "/pages/cart/cart",
            text: "购物车",
            iconPath: "cart-o",
            selectedIconPath: "cart-o"
            
          },
          {
            pagePath: "/pages/user/user",
            text: "我的",
            iconPath: "manager-o",
            selectedIconPath: "manager-o" 
          }
        ]
    },
    methods: {
        onChange(event) {
            console.log( event.detail)
            // event.detail 的值为当前选中项的索引
            this.setData({
                active: event.detail
            });
             //小程序切换页面 tabBar
             wx.switchTab({
                url: this.data.list[event.detail].pagePath,
              })
        },
    }

})